<template>
	<view class="page">
		<article class="weui-article sc-article ">
			<h1>{{detail.title}}</h1>
			<p><span class="f-gray">{{detail.publishTime}}</span> <span class="f-blue" style="margin-left: 10rpx;">浏览{{detail.viewNum}}</span></p>
			<section>
				<rich-text :nodes="nodes"></rich-text>
			</section>
		</article>
	</view>
</template>

<script>
	import htmlParser from '@/common/html-parser.js'
	export default {
		data() {
			return {
				detail: {},
				nodes: []
			}
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
			    title: '新的标题'
			});
			this.getData(option.id)
		},
		methods: {
			getData(id){
				let _self = this;
				this.$get(this.$api.cmsDetail, {id: id}).then(res => {
					if (res.code == 0) {
						_self.detail = res.detail;
						_self.nodes = htmlParser(res.detail.content);
					} else {
						uni.showModal({
							title: '操作提示',
							content: res.msg,
							showCancel: false
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>
